package com.wcity.manage.web.property;

import com.wcity.manage.common.enums.Code;
import com.wcity.manage.dao.dal.model.PageModel;
import com.wcity.manage.dao.model.Block;
import com.wcity.manage.dao.model.OnDuty;
import com.wcity.manage.service.property.PropertyOnDutyService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 前端值班管理
 * Created by zm on 2016/12/19.
 */
@Controller
public class IPropertyOnDutyAct {

    @Resource private PropertyOnDutyService propertyOnDutyService;

    /**
     * 获取值班列表
     * @param pageModel
     * @param blockId
     * @return
     */
    @RequestMapping ("i_duty_list")
    @ResponseBody
    public Map<String,Object> IDutyList ( PageModel pageModel, String blockId ) {

        Map<String,Object> map = new HashMap<>();
        OnDuty duty = new OnDuty();
        duty.setBlockId( Integer.parseInt(blockId) );
        pageModel.setParams( duty );
        try{
            Block block = propertyOnDutyService.getUserInfo (blockId);
            List<OnDuty> dutyList = propertyOnDutyService.getIDutyList ( pageModel );
            map.put("telePhone",block.getTelephone());
            map.put("dutyList",dutyList);
            map.put("retCode", Code.SUCCESS.getCodeNum());
            map.put("retDesc","请求成功");
        }catch (Exception e){
            e.printStackTrace();
            map.put("err","服务器异常");
        }
        return map;
    }

}
